﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:controls="clr-namespace:Rabbit.Controls;assembly=Rabbit.Controls"
             xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" x:Class="MicroBlogClient.UCSearch"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <DataTemplate x:Key="StatusItemTemplate">
            <DockPanel Margin="0,10,0,10" x:Name="grid" Background="White">
                <!--User Picture-->
                <Border VerticalAlignment="Top" Width="40" >
                    <Border BorderBrush="White" DockPanel.Dock="Left" CornerRadius="5" Height="40" Width="40" BorderThickness="1">
                        <Image Stretch="UniformToFill" MouseEnter="UserHeadPicture_MouseEnter"  MouseLeave="UserHeadPicture_MouseLeave"
                               Source="{Binding User.ProfileImageUrl, Converter={StaticResource ImageConverter}, IsAsync=True}" />
                    </Border>
                </Border>
                <!--Status Text-->
                <StackPanel Margin="10,0,0,0">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock TextWrapping="Wrap" Canvas.Top="0" Width="Auto"><Hyperlink CommandParameter="{Binding User.Id}"  Click="OpenUserPage_Click"><Run Text="{Binding User.ScreenName}"/></Hyperlink></TextBlock>
                        <ContentControl Visibility="{Binding User.Verified, Converter={StaticResource BooleanToVisibilityConverter}}" Content="{DynamicResource CertificateUser}"/>
                        <TextBlock Foreground="Gray" Margin="5,0,0,0" Text="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter}, IsAsync=True}"/>
                    </StackPanel>
                    <DockPanel Margin="10,10,0,0">
                        <!--Status text-->
                        <controls:TextBlockEx Foreground="{DynamicResource StatusForegroundBrush}" LineHeight="20" Text="{Binding Text, IsAsync=True}" DockPanel.Dock="Top" TextWrapping="Wrap">
                            <controls:TextBlockEx.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="复制" x:Name="menuCopyStatus" CommandParameter="{Binding Text}" Click="menuCopyStatus_Click"/>
                                </ContextMenu>
                            </controls:TextBlockEx.ContextMenu>
                        </controls:TextBlockEx>
                        <controls:ImageEx 
                            Source="{Binding SmallPic, Converter={StaticResource ImageConverter}, IsAsync=True}"  
                            LargerPictureSource="{Binding MiddlePic}" Cursor="Hand" x:Name="statusImage" PreviewMouseLeftButtonUp="statusImage_PreviewMouseLeftButtonUp" HorizontalAlignment="Left" Stretch="None">
                            <controls:ImageEx.ToolTip>点击看大图</controls:ImageEx.ToolTip>
                        </controls:ImageEx>
                    </DockPanel>
                </StackPanel>
            </DockPanel>
        </DataTemplate>
        <DataTemplate x:Key="UserItemsTemplate">
            <DockPanel Margin="0,10,0,10" x:Name="grid" Background="White">
                <!--User Picture-->
                <Border VerticalAlignment="Top" Width="40" >
                    <Border BorderBrush="White" DockPanel.Dock="Left" CornerRadius="5" Height="40" Width="40" BorderThickness="1">
                        <Image Stretch="UniformToFill"  MouseEnter="UserHeadPicture_MouseEnter"  MouseLeave="UserHeadPicture_MouseLeave"  Source="{Binding ProfileImageUrl, Converter={StaticResource ImageConverter}, IsAsync=True}" />
                    </Border>
                </Border>
                <!--Status Text-->
                <StackPanel Margin="10,0,0,0">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock TextWrapping="Wrap" Canvas.Top="0" Width="Auto"><Hyperlink CommandParameter="{Binding User.Id}"  Click="OpenUserPage_Click"><Run Text="{Binding ScreenName}"/></Hyperlink></TextBlock>
                        <ContentControl Visibility="{Binding Verified, Converter={StaticResource BooleanToVisibilityConverter}}" Content="{DynamicResource CertificateUser}"/>
                        <TextBlock  Margin="10,0,0,0" Visibility="{Binding IsMouseOver, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}">
                        	 <Hyperlink CommandParameter="{Binding Id}" Click="MakeFriends_Click" ><Run Text="关注此人"/></Hyperlink></TextBlock>
                    </StackPanel>
                    <StackPanel Margin="10,10,0,0">
                        <TextBlock Foreground="{DynamicResource StatusForegroundBrush}" LineHeight="20" Text="{Binding Location}" TextWrapping="Wrap"/>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="粉丝数："/>
                            <TextBlock LineHeight="20" Text="{Binding FollowersCount}"  Foreground="Red" TextWrapping="Wrap"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="微博数："/>
                            <TextBlock LineHeight="20" Text="{Binding StatusesCount}"  Foreground="Red" TextWrapping="Wrap"/>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </DockPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <Border Style="{DynamicResource MainContentBackground}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="37"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" Height="25">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="40"/>
                    </Grid.ColumnDefinitions>
                    <Border BorderBrush="#cecece" Background="White" CornerRadius="5" Margin="10,0,0,0">
                        <Border.Effect>
                            <DropShadowEffect ShadowDepth="0.1" Color="#737373" />
                        </Border.Effect>
                        <Canvas>
                            <TextBox x:Name="txtSearchKeyword"  Canvas.Left="0"  KeyUp="txtSearchKeyword_KeyUp"  Width="180" Background="{x:Null}" MinWidth="185" BorderBrush="{x:Null}" Padding="10,5,0,2"   BorderThickness="0" />
                            <Menu Canvas.Right="0" BorderThickness="0"/>
                            <ComboBox  Canvas.Right="0" Style="{DynamicResource SimpleComboBox}"  Margin="0,0,5,0"   SelectedIndex="0" x:Name="cmbSearchType">
                                <ComboBoxItem x:Name="cmItemStatus" Background="White" Content="搜微博"/>
                                <ComboBoxItem x:Name="cmItemUser" Background="White"  Content="搜   人"/>
                            </ComboBox>
                        </Canvas>
                    </Border>
                    <Button Grid.Column="2"   Background="{x:Null}"  BorderThickness="0" x:Name="btnSearch" Click="btnSearch_Click"  Height="30" Width="30"  VerticalAlignment="Center">
                        <controls:ImageEx Source="{DynamicResource SearchButton}"/>
                    </Button>
                </Grid>
                <ListBox Canvas.Left="0" Grid.Row="1" x:Name="lstSearchResult" BorderThickness="0"
                                                                 ItemContainerStyle="{DynamicResource ListBoxItemStyle}"  Margin="0"
                                                                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"  
                                                                 ScrollViewer.CanContentScroll="False"
                                                                 ItemTemplate="{StaticResource ResourceKey=StatusItemTemplate}" 
                                                                 Foreground="Black"/>
                <StackPanel VerticalAlignment="Bottom" Grid.Row="1" HorizontalAlignment="Center"  Orientation="Horizontal">
                    <TextBlock><Hyperlink x:Name="linkFirstPage" Click="linkFirstPage_Click" IsEnabled="False"><Run Text="返回首页"/></Hyperlink><Run Text="  "/><Run Text=" "/><Hyperlink x:Name="linkPreviousePage" Click="linkPreviousePage_Click" IsEnabled="False"><Run Text="上一页"/></Hyperlink><Run Text="  "/><Run Text=" "/><Hyperlink x:Name="linkNextPage" Click="linkNextPage_Click" IsEnabled="False"><Run Text="下一页"/></Hyperlink></TextBlock>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</UserControl>
